dcmotor32 2.2.0
Loading...
Searching...
No Matches
dcmotor32


DC Motor 32 Click

DC Motor 32 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Mar 2026.
  • Type : SPI type

Software Support

Example Description

This example demonstrates the use of the DC Motor 32 Click board for controlling a DC motor. The application switches between different operation modes (forward, brake, reverse, and off) and measures the output current in each state.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.DCMotor32

Example Key Functions

Application Init

Initializes the logger and DC Motor 32 Click driver, and applies the default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
dcmotor32_cfg_t dcmotor32_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
dcmotor32_cfg_setup( &dcmotor32_cfg );
if ( DCMOTOR32_OK != dcmotor32_init( &dcmotor32, &dcmotor32_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( DCMOTOR32_OK != dcmotor32_default_cfg ( &dcmotor32 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ DCMOTOR32_OK
Definition dcmotor32.h:215
#define DCMOTOR32_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition dcmotor32.h:161
void application_init(void)
Definition main.c:36
#define MIKROBUS_POSITION_DCMOTOR32
Definition main.c:30

Application Task

Cycles through motor operation modes, measures the output current, and logs the results to the serial terminal.

void application_task ( void )
{
float current = 0;
{
log_printf( &logger, " MODE: Forward\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
if ( DCMOTOR32_OK == dcmotor32_get_out_current ( &dcmotor32, &current ) )
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
{
log_printf( &logger, " MODE: Brake\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
if ( DCMOTOR32_OK == dcmotor32_get_out_current ( &dcmotor32, &current ) )
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
{
log_printf( &logger, " MODE: Reverse\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
if ( DCMOTOR32_OK == dcmotor32_get_out_current ( &dcmotor32, &current ) )
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
{
log_printf( &logger, " MODE: Off\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
if ( DCMOTOR32_OK == dcmotor32_get_out_current ( &dcmotor32, &current ) )
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
}
#define DCMOTOR32_CONTROL_MODE_HALF_BRIDGE_A_TRI_STATE
Definition dcmotor32.h:90
#define DCMOTOR32_CONTROL_MODE_SLOW_DECAY_LSA
Definition dcmotor32.h:79
#define DCMOTOR32_CONTROL_MODE_FORWARD_HSB
Definition dcmotor32.h:82
#define DCMOTOR32_CONTROL_MODE_REVERSE_HSA
Definition dcmotor32.h:87
void application_task(void)
Definition main.c:72

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.